#include <bits/stdc++.h>
using namespace std;
int T,n,m,L,V,d[100007],v[100007],a[100007],vis[1000007],p[100007],ans,maxn,temp,s;
int LR(int x)
{
    int l=1,r=m;
    while(l<r)
    {
        int mid=(l+r)/2;
        if(p[mid]>x)    r=mid-1;
        if(p[mid]<=x)   l=mid+1;
    }
    return l;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--)
    {
        ans=0,maxn=0;
        memset(vis,0,sizeof(vis));
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int i=1;i<=n;i++)
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
        for(int j=1;j<=m;j++)
            scanf("%d",&p[j]);
        sort(p+1,p+m+1);
        temp=m;
        for(int i=1;i<=n;i++)
        {
            s=0;
             if(v[i]>=V && a[i]>0 && d[i]<p[m])
            {
                ans++;
                if(vis[m]==0)
                {
                    vis[m]=1;
                    temp--;
                }
            }
            if(v[i]<V && a[i]>0)
            {
                s=(V*V-v[i]*v[i])/(2*a[i]);
                if(d[i]+s<p[m]);
                {
                    ans++;
                    if(vis[m]==0)
                    {
                        vis[m]=1;
                        temp--;
                    }
                }
            }
            if(v[i]>V && a[i]==0 && vis[m]==0)
            {
                vis[m]=1;
                temp--;
                ans++;
            }
            if(v[i]>V && a[i]<0)
            {
                if((v[i]*v[i]-V*V)%(2*abs(a[i]))!=0) s++;
                s=s+(V*V-v[i]*v[i])/(2*abs(a[i]));
                int xb=LR(d[i]);
                if(p[xb+1]>=d[i]+s)
                    if(vis[xb+1]==0)
                    {
                        ans++;
                        vis[xb+1]=1;
                        temp--;
                    }
            }
        }
        printf("%d %d\n",ans,temp);
    }
    return 0;
}
